/*
The MIT License (MIT)

Copyright (c) 2013 Mike Dapiran, Brian May, Richard Pospesel, and Bert Wierenga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software 
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#pragma once

#include "Hogshead.Common.h"
#include "Hogshead.Core.h"

#include "../Directors/IProcess.h"
#include "../HLSLCPPDeclarations/GUITransform.fx"

struct ID3D11Buffer;

namespace Hogshead
{
	namespace DX11Rendering
	{
		//class IGUIObject;
		class GUIComponent;
		class GUITexture;
		class GUIButton;
		//class GUIToggle;
		class VertexShader;
		class GeometryShader;
		class PixelShader;
		class RasterizerState;
		class BlendState;
		class SamplerState;
		class DepthStencilState;


		/**
		* This class is the process that will render all IGUIObjects that register with it.
		*
		* @see IGUIObject
		* @see Camera
		* @see IProcess
		* @see IDirector
		*
		* @author Ben Dapkiewicz
		*/
		class GUIProcess : public IProcess
		{
			ProcessH(Hogshead::DX11Rendering::GUIProcess, GUIProcess)

		public:
			/**
			* Default Constructor; Nulls WVP, shaders, and states.
			*/
			GUIProcess(void);

			/**
			* Destructor; Only responsibility is to delete the WVP buffer.
			*/
			~GUIProcess(void);

			/**
			* initialize method; Sets up the WVP, sets up the WVP buffer, and nulls the shaders and states.
			*/
			void initialize();

			/**
			* registerComponent method; Registers only IGUIObject components.
			*
			* @param in_component The IGUIObject component to be registered.
			*/
			void registerComponent(IComponent* in_component);

			/**
			* render method; Iterates through the registered IGUIObject components and goes through the process to render them.
			*
			* @param in_active_camera The camera object. Note that this may not be used, as the IGUIObjects will be rendered in screen space.
			*/
			void render(Camera* in_active_camera, HashSet<void*>* in_nonculled_components);


		private:
			//position and buffer
			GUITransform2D _gui_transform;
			ID3D11Buffer* _gui_transform_buffer;

			//the shaders
			VertexShader* _prev_vertex_shader;
			PixelShader* _prev_pixel_shader;
			GeometryShader* _prev_geometry_shader;

			//the states
			RasterizerState* _prev_rasterizer_state;
			BlendState* _prev_blend_state;
			SamplerState* _prev_sampler_state;
			DepthStencilState* _prev_depth_stencil_state;
		};
	}
}